package models

import scala.slick.driver.MySQLDriver.simple._
import Tables._

object User {

  def findUser(id: Int): UserRow = {
    SlickDB.database.withSession {
      implicit session =>
        Tables.User.filter(_.id === id).first
    }
  }
  
    def findUser(name:String): UserRow = {
    SlickDB.database.withSession {
      implicit session =>
        Tables.User.filter(_.username === name).first
    }
  }

  def verify(name: String, password: String): Boolean = {
    SlickDB.database.withSession {
      implicit session =>
        Tables.User.filter(_.username === name).
        filter(_.password === password).firstOption.isDefined
    }
  }
}